<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
// 引入CnNotify组件
import CnNotify from "@/components/CnNotify/index.vue";
export default {
  name: "App",
  components: {
    /* eslint-disable */
    CnNotify,
  },
  mounted() {
    this.watchUpdate();
  },
  methods: {
    watchUpdate() {
      window.addEventListener("onmessageUpdate", (res) => {
        let msg = res.detail.msg,
          version = res.detail.version;
        console.log("version update:" + version);
        this.$notify({
          title: "Version update prompt",
          duration: 0,
          position: "bottom-right",
          dangerouslyUseHTMLString: true,
          message: this.$createElement("CnNotify", {
            // 使用自定义组件
            ref: "CnNotify",
            props: {
              msg: msg,
              version: version,
            },
          }),
          customClass: "versionNotifyStyle", //自定义类名
        });
      });
    },
  },
};
</script>
